import request from '../utils/request';
import constant from '../constant/constant'
import qs from 'qs';

/**
 * 获取专利数据列表
 */
export function getPatentDataTableList(payload){
    let option = {
        method: 'GET',
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }

    return request(constant.serverUrl + `/tvs/api/patents/list/bypage?limit=${payload.limit}&page=${payload.page}`, option)
}

/**
 * 单个录入专利数据
 */
export function uploadPatentData(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
		    "Content-Type": "application/x-www-form-urlencoded"
		},
		mode: "cors",
    } 

    return request(constant.serverUrl+'/tvs/api/patents/create',option)
}

/**
 * 通过id删除专利数据
 */
export function deletePatentById(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload,{arrayFormat:'repeat'}),
        headers: {
		    "Content-Type": "application/x-www-form-urlencoded"
		},
		mode: "cors",
    } 

    return request(constant.serverUrl+'/tvs/api/patents/delete/byidArr',option)
}

/**
 * 获取技术热点html
 */
export function getTechnologyHotspot(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload,{arrayFormat:'repeat'}),
        headers: {
		    "Content-Type": "application/x-www-form-urlencoded"
		},
		mode: "cors",
    } 

    return request(constant.serverUrl+'/tvs/api/patents/wordfrequency/show',option)
}

/**
 * 获取技术聚类html
 */
export function getTechnologyClustering(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload,{arrayFormat:'repeat'}),
        headers: {
		    "Content-Type": "application/x-www-form-urlencoded"
		},
		mode: "cors",
    } 

    return request(constant.serverUrl+'/tvs/api/patents/clustering/show',option)
}

/**
 * 根据条件查询专利数据
 */
export function getPatentDataSearch(payload){
    console.log(payload)
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
		    "Content-Type": "application/x-www-form-urlencoded"
		},
		mode: "cors",
    } 

    return request(constant.serverUrl+'/tvs/api/patents/list/bypage',option)
}